package com.backend.demo1.models;

public class User {

    private Long id;
    private String Username;
    private String Password;
    private Role role; // 用户所属角色
    private Department department; // 关联部门对象
    private Long departmentId; // 外键字段，对应数据库中的 department_id
    private String captcha;

    // 无参构造方法
    public User() {}

    // Getter 和 Setter 方法

    public Long getid() {
        return id;
    }

    public void setid(Long id) {
        this.id = id;
    }

    public String getUsername() {
        return Username;
    }

    public void setUsername(String username) {
        this.Username = username;
    }

    public String getPassword() {
        return Password;
    }

    public void setPassword(String password) {
        this.Password = password;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public Long getRoleid() {
        return role != null ? role.getid() : null;
    }

    public void setRoleid(Long roleid) {
        if (roleid != null) {
            Role newRole = new Role();
            newRole.setid(roleid);
            this.role = newRole;
        } else {
            this.role = null;
        }
    }

    // ====== 新增的 Department 相关字段和方法 ======

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    public Long getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(Long departmentId) {
        this.departmentId = departmentId;
    }

    public String getCaptcha() {
        return captcha;
    }

    public String setCaptcha(String captcha) {
        return this.captcha = captcha;
    }
}